<template>
	<rui-card title="邀请好友" more="可开启自动兑换" @change="$rui.route('/pages/user/seting/seting')">
		<view class="invite-box">
			<view class="member">
				<image class="img" :src="item.avatar" v-for="(item, index) in info.user" :key="index"></image>
				<view class="avatar" v-for="i in (4 - (info.user ? info.user.length:0))" :key="i">
					+
				</view>
			</view>
			<view class="btn" @click="exchange">
				立即兑换
			</view>
		</view>
		<view class="tips">
			{{info.tips}}
		</view>
	</rui-card>
	<rui-card title="兑换方式">
		<view class="mode">
			<view class="item">
				<uni-icons type="pyq" size="40" color="#ffb100"></uni-icons>
				<view class="name">
					分享好友
				</view>
			</view>
			<uni-icons type="arrow-right" size="15" color="#999"></uni-icons>
			<view class="item">
				<uni-icons type="staff-filled" size="40" color="#ffb100"></uni-icons>
				<view class="name">
					新人注册并登录
				</view>
			</view>
			<uni-icons type="arrow-right" size="15" color="#999"></uni-icons>
			<view class="item">
				<uni-icons type="auth-filled" size="40" color="#3165cc"></uni-icons>
				<view class="name">
					自动兑换Pro会员
				</view>
			</view>
		</view>

	</rui-card>
	<rui-card title="我的当月成就">
		<view class="achieve">
			<view class="item">
				<view class="person">
					{{info.exchange_total}}
				</view>
				<view class="name">
					本周注册并登录
				</view>
			</view>
			<view class="item">
				<view class="week">
					{{info.exchange_month}}
				</view>
				<view class="name">
					本周兑换
				</view>
			</view>
		</view>
	</rui-card>
	<rui-card title="我的累计成就">
		<view class="achieve">
			<view class="item">
				<view class="person">
					{{info.promo_month}}
				</view>
				<view class="name">
					总注册并登录
				</view>
			</view>
			<view class="item">
				<view class="week">
					{{info.promo_total}}
				</view>
				<view class="name">
					总兑换
				</view>
			</view>
		</view>
	</rui-card>
	<view class="fixed">
		<!-- <rui-button title="立即邀请" @click="onInvite"></rui-button> -->
		<button class="share_btn" plain="true" open-type="share">
			立即邀请
		</button>
	</view>

</template>

<script setup>
	import {
		ref,
		onMounted
	} from "vue"
	// import {
	// 	getInviteInfo,
	// 	setInviteExchange
	// } from "@/common/api.js"

	let info = ref({})


	onMounted(() => {
		getData()
	})

	const exchange = () => {
		// setInviteExchange().then(res => {

		// })
	}

	const getData = () => {
		// getInviteInfo().then(res => {
		// 	info.value = res.data
		// })
	}

	const emits = defineEmits(['change'])
	const onInvite = () => {
		emits('change')
	}
</script>

<style lang="scss" scoped>
	.fixed {
		position: fixed;
		bottom: 20rpx;
		left: 20rpx;
		width: calc(100% - 40rpx);
		z-index: 9;
	}

	.btn {
		color: #fff;
		border-radius: 10rpx;
		font-size: 24rpx;
		padding: 12rpx 30rpx;
		height: 40rpx;
		line-height: 40rpx;
		box-shadow: 0rpx 5rpx 15rpx rgba(0, 0, 0, .2);
		background-image: linear-gradient(to right, #907fd8, #3165cc);
		text-align: center;

	}

	.share_btn {
		color: #fff;
		border-radius: 10rpx;
		box-shadow: 0rpx 5rpx 15rpx rgba(0, 0, 0, .2);
		background-image: linear-gradient(to right, #907fd8, #3165cc);
		text-align: center;
	}

	.mode {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 40rpx 0 20rpx;

		.item {
			text-align: center;

			.name {
				font-size: 24rpx;
				color: #333;
			}
		}
	}

	.tips {
		font-size: 24rpx;
		color: #666;
		text-align: center;
		margin: 20rpx 0;
		color: #999;
	}

	.achieve {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 40rpx 0 20rpx;

		.item {
			width: 50%;
			text-align: center;
			color: #ffb100;

			.person {
				font-size: 70rpx;
				font-weight: bold;

				&::after {
					content: "人";
					font-size: 28rpx;
				}
			}

			.week {
				font-size: 70rpx;
				font-weight: bold;

				&::after {
					content: "周";
					font-size: 28rpx;
				}
			}

			.name {
				color: #333;
				font-size: 24rpx;
			}
		}
	}

	.invite-box {
		display: flex;
		justify-content: space-between;
		align-items: center;



		.member {
			display: flex;
			flex-wrap: wrap;
			width: calc(100% - 160rpx);

			.img {
				width: 96rpx;
				height: 96rpx;
				border-radius: 50%;
				margin: 15rpx;
			}

			.avatar {
				width: 90rpx;
				height: 90rpx;
				line-height: 85rpx;
				background-image: linear-gradient(to right, #ffd88f, #fff8a3);
				text-align: center;
				border-radius: 50%;
				margin: 15rpx;
				font-size: 50rpx;
				color: #fff;
				border: 3rpx dashed #ffc56e
			}
		}
	}
</style>